package cn.tedu.ivos.audit.controller;

import cn.tedu.ivos.audit.pojo.dto.AuditQuery;
import cn.tedu.ivos.audit.pojo.dto.AuditSaveParam;
import cn.tedu.ivos.audit.pojo.entity.Audit;
import cn.tedu.ivos.audit.pojo.vo.AuditVO;
import cn.tedu.ivos.audit.service.AuditService;
import cn.tedu.ivos.base.response.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/v1/audit/")
@Tag(name = "审批模块")
@Slf4j
public class AuditController {
    @Autowired
    private AuditService auditService;

    @GetMapping("select")
    @Operation(summary = "查询审核列表")
    @ApiOperationSupport(order = 10)
    public JsonResult selectAuditByUsername(AuditQuery auditQuery) {
        log.debug("开始处理【查询审核列表】的请求，参数：{}", auditQuery);
        List<AuditVO> list = auditService.selectAuditByUsername(auditQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("update")
    @Operation(summary = "审核申请单")
    @ApiOperationSupport(order = 20)
    public JsonResult updateApplication(AuditSaveParam auditSaveParam){
        log.debug("开始处理【通过审批】的请求，参数：{}", auditSaveParam);
        auditService.updateAudit(auditSaveParam);
        return JsonResult.ok();
    }
}
